package it.polimi.traveldream.web.beans.shared;

import it.polimi.traveldream.ejbclient.dtos.TransportDTO;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;


@FacesConverter(forClass=TransportDTO.class,value="transportConverter")
public class SelectTransportsConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String value) {
		TransportDTO transport = new TransportDTO();
		transport.setId(Integer.parseInt(value));
		return transport;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component, Object value) {
		return String.valueOf(((TransportDTO) value).getId());
	}

}
